package com.ruoyi.admin.service.app.impl;

import com.ruoyi.admin.domain.LlmAppSettings;
import com.ruoyi.admin.domain.LlmAppSettingParam;
import com.ruoyi.admin.domain.LlmFaqCategory;
import com.ruoyi.admin.mapper.LlmAppSettingsMapper;
import com.ruoyi.admin.mapper.LlmAppSettingsParamMapper;
import com.ruoyi.admin.service.app.LlmAppSettingsParamService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
@Slf4j
@RequiredArgsConstructor
public class LlmAppSettingsParamServiceImpl implements LlmAppSettingsParamService {

    private final LlmAppSettingsParamMapper llmAppSettingsParamMapper;

    private final LlmAppSettingsMapper llmAppSettingsMapper;

    @Override
    public boolean addAppSettingParam(LlmAppSettingParam llmAppSettingParam) {
        return insertAppSettingParam(llmAppSettingParam);
    }

    public boolean insertAppSettingParam(LlmAppSettingParam llmAppSettingParam) {
        llmAppSettingParam.setId(IdUtils.fastSimpleUUID());
        LlmAppSettings settings = llmAppSettingsMapper.selectById(llmAppSettingParam.getAppSettingsId());
        if (settings == null) {
            throw new RuntimeException("无效的 appSettingsId");
        }
        llmAppSettingParam.setAppSettingsId(settings.getId());
        return llmAppSettingsParamMapper.insert(llmAppSettingParam) > 0;
    }
}
